<template>
  <div class="app-container">
    <h2>待办任务</h2>
    <el-table :data="tenantList">
      <el-table-column type="selection" width="55" align="center"/>
      <el-table-column label="负责人" align="center" prop="task.assignee"/>
      <el-table-column label="任务id" align="center" prop="task.id"/>
      <el-table-column label="定义id" align="center" prop="task.processDefinitionId"/>
      <el-table-column label="实例id" align="center" prop="task.processInstanceId"/>
      <el-table-column label="操作" align="center" width="180px" class-name="small-padding fixed-width">
        <template slot-scope="scope">
          <el-button
            size="mini"
            type="text"
            icon="el-icon-edit"
            @click="auditBusiness(scope.row)"
            v-hasPermi="['business:tenant:edit']"
          >审核
          </el-button>
        </template>
      </el-table-column>
    </el-table>
  </div>

</template>

<script>
import {queryUserTaskByUserName, completeUserTaskById} from "@/api/business/tenant";

export default {
  name: "taskList",
  data(){
    return{
      tenantList:[],
      vo: {
        taskId: null,
        auditFlag: null,
        message: '',
        processInstanceId: null
      }
    }
  },
  methods:{
    // 我的待办
    handleQueryTask(){
      queryUserTaskByUserName().then(response=>{
        console.log(response)
        this.tenantList = response.data
      })
    },
    // 审核按钮操作
    auditBusiness(row) {
      this.vo.taskId = row.task.id
      this.vo.auditFlag = true
      this.vo.message = '同意审批'
      this.vo.processInstanceId = row.task.processInstanceId
      completeUserTaskById(this.vo).then(response=>{
        console.log(response)
        this.$message.success('审批通过')
        this.handleQueryTask()
      })
    }
  },
  created() {
    this.handleQueryTask()
  }
}
</script>

<style scoped>

</style>
